﻿package net.wangit.jdbc.sqltype;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;

public class ClobImpl implements Clob {

	private Reader reader;
	private int length;

	public ClobImpl(String string) {
		reader = new StringReader(string);
		length = string.length();
	}

	public ClobImpl(Reader reader, int length) {
		this.reader = reader;
		this.length = length;
	}

	public long length() throws SQLException {
		return (long) length;
	}

	public void truncate(long pos) throws SQLException {
		excep();
	}

	public InputStream getAsciiStream() throws SQLException {
		excep();
		return null;
	}

	public OutputStream setAsciiStream(long pos) throws SQLException {
		excep();
		return null;
	}

	public Reader getCharacterStream() throws SQLException {
		return reader;
	}

	public Writer setCharacterStream(long pos) throws SQLException {
		excep();
		return null;
	}

	public String getSubString(long pos, int len) throws SQLException {
		excep();
		return null;
	}

	public int setString(long pos, String string) throws SQLException {
		excep();
		return 0;
	}

	public int setString(long pos, String string, int i, int j)
			throws SQLException {
		excep();
		return 0;
	}

	public long position(String string, long pos) throws SQLException {
		excep();
		return 0L;
	}

	public long position(Clob colb, long pos) throws SQLException {
		excep();
		return 0L;
	}

	private static void excep() {
		throw new UnsupportedOperationException(
				"Blob may not be manipulated from creating session");
	}

	@Override
	public void free() throws SQLException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Reader getCharacterStream(long arg0, long arg1) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}
}
